﻿using System;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Media3D;

using SBPweb.Modules.Smartparts;

using SBPweb.MediaCenter.Tools.WPF.Controls;
using SBPweb.MediaCenter.Tools.WPF.Extenders;
using SBPweb.MediaCenter.Tools.WPF.Resources;

namespace SBPweb.MediaCenter.Modules.Player.WPF.Controls
{

    public class MenuItem : Model3DSVisual3D, IMenuItem
    {

        #region Private fields

        private TagDictionary tag = new TagDictionary();

        #endregion

        #region Constructor logic

        public MenuItem(string fileName)
            : base(fileName)
        {
            TagDictionary.SetTag(this, tag);
        }

        public MenuItem(Stream stream)
            : base(stream)
        {
            TagDictionary.SetTag(this, tag);
        }

        #endregion

        #region Property accessors

        public string Text
        {
            get
            {
                return "Viewer";
            }
        }

        public Vector3D Scale
        {
            get
            {
                return tag.Get<string, Vector3D>("Scale");
            }
            set
            {
                tag.Put<string, Vector3D>("Scale", value);
            }
        }

        public Vector3D Offset
        {
            get
            {
                return tag.Get<string, Vector3D>("Offset");
            }
            set
            {
                tag.Put<string, Vector3D>("Offset", value);
            }
        }

        public Color BackgroundColor
        {
            get
            {
                return tag.Get<string, Color>("BackgroundColor");
            }
            set
            {
                tag.Put<string, Color>("BackgroundColor", value);
            }
        }

        #endregion

        #region Events

        public event EventHandler<MenuEventArgs> Pressed;

        public event EventHandler<MenuEventArgs> Selected;

        #endregion

        #region Methods

        public void Press()
        {
            if (Pressed != null)
            {
                Pressed(this, new MenuEventArgs(this));
            }
        }

        public void Select()
        {
            if (Selected != null)
            {
                Selected(this, new MenuEventArgs(this));
            }
        }

        #endregion

    }

}